<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/wpui-admin/wp-ewallet-admin/static/plugin/layuimini/lib/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/wpui-admin/wp-ewallet-admin/static/plugin/layuimini/css/public.css" media="all">

    <style>
        .table-row-bar{
            padding: 0px 5px;
            cursor: pointer;
        }

        .date-icon{
            position: absolute;
            top: 7px;
            right: 10px;
            font-size: 20px;
        }
    </style>
</head>
<body>
<div id="container" class="layuimini-container">
    <div class="layuimini-main">
        <h2><b>申请单列表</b></h2>

        <div style="margin: 10px 0px 10px 0px">
            <form class="layui-form" action="" id="myform" lay-filter="myform">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label" style="padding: 9px 15px 9px 0px;">开始时间：</label>
                        <div class="layui-input-inline" style="width: 180px;">
                            <input type="text" name="startTime" v-model="startTime" class="layui-input" id="startTime">
                            <i class="layui-icon layui-icon-date date-icon"></i>
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label" style="padding: 9px 15px 9px 0px;">结束时间：</label>
                        <div class="layui-input-inline" style="width: 180px;">
                            <input type="text" name="endTime" v-model="endTime" class="layui-input" id="endTime">
                            <i class="layui-icon layui-icon-date date-icon"></i>
                        </div>
                    </div>

                    <div class="layui-inline" style="float: right;margin-right:0px;">
                        <a class="layui-btn layui-btn-normal" lay-submit="" style="width: 100px;"
                           lay-filter="data-search-btn" @click="search">查询</a>
                        <a class="layui-btn layui-btn-normal" lay-submit="" style="width: 100px;"
                           lay-filter="data-reset-btn" @click="reset">重置</a>
                    </div>
                </div>
            </form>
        </div>

        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
    </div>
</div>

<!-- Vue 表达式与Layui模板表达式冲突，需放在Vue Scope 外边 -->
<script type="text/html" id="operTpl">
    <a class="table-row-bar" lay-event="detail" style="color: #1890FF;">{{d.reqOrderId}}</a>
</script>

<script type="text/html" id="statusTpl">
    {{#  if(d.orderStatus == '1000'){ }}
    <span class="layui-badge layui-bg-blue">待处理</span>
    {{# } else { }}
    <!--订单状态是2000 请求类型为 提币-->
    {{#        if(d.reqType == '1000'){ }}
    {{#             if(d.operResult == '2000' )  { }}
                    <span class="layui-badge layui-bg-red">已拒绝</span>
    {{#             }else{ }}
    {{#                if(d.transResult == '1000' && d.operResult =='1000'){ }}
                        <span class="layui-badge layui-bg-blue">已转待确认</span>
    {{#                 } }}
    {{#                if(d.transResult == '2000' && d.operResult =='1000'){ }}
                        <span class="layui-badge layui-bg-green">已转成功</span>
    {{#                } }}
    {{#                if(d.transResult == '3000' && d.operResult  =='1000' ){ }}
                        <span class="layui-badge layui-bg-red">转账失败</span>
    {{#                } }}
    {{#                if((d.transResult == null && d.operResult =='1000') || (d.transResult == null && d.operResult ==null) ){ }}
                        <span class="layui-badge layui-bg-green">已同意</span>
    {{#                } }}
    {{#            } }}
    {{#         } }}
    <!--已处理 兑换状态信息-->
    {{#         if(d.reqType == '2000'){ }}
    {{#            if(d.operResult == '2000')  { }}
    <span class="layui-badge layui-bg-red">兑换失败</span>
    {{#            }else{ }}
    <span class="layui-badge layui-bg-green">兑换成功</span>
    {{#            } }}
    {{#         } }}
    {{#  } }}



</script>

<script type="text/html" id="applyTypeTpl">
    {{# if(d.reqType == '1000'){ }}
    <span style="color: #1890FF;">提币</span>
    {{# } else { }}
    <span style="color: #5FB878;">兑换</span>
    {{#  } }}
</script>

<script src="/wpui-admin/wp-ewallet-admin/static/js/jquery-3.4.1.min.js"></script>
<script src="/wpui-admin/wp-ewallet-admin/static/plugin/layuimini/lib/layui/layui.js" charset="utf-8"></script>
<script src="/wpui-admin/wp-ewallet-admin/module/index/config.js" charset="utf-8"></script>
<script src="/wpui-admin/wp-ewallet-admin/global/wp.js" charset="utf-8"></script>
<script src="/wpui-admin/wp-ewallet-admin/static/js/vue.js" charset="utf-8"></script>
<script src="/wpui-admin/wp-ewallet-admin/static/js/vue-i18n.js" charset="utf-8"></script>
<script src="/wpui-admin/wp-ewallet-admin/global/wp-i18n.js" charset="utf-8"></script>
<script src="/wpui-admin/wp-ewallet-admin/global/wp-project.js" charset="utf-8"></script>

<script>
    layui.use(['form', 'table', 'laydate'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table,
            laydate = layui.laydate;

        var vm = new Vue({
            el: '#container',
            i18n: wp.i18n(),
            data: {
                reqType: '',
                startTime: '',
                endTime: '',
                moneyType: window.data.moneyType
            },
            mounted: function () {
                this.init();
                this.getMentionMoneyByMoneyType();
            },
            methods: {
                init: function () {
                    var that = this;
                    laydate.render({
                        elem: '#startTime',
                        type: 'datetime'
                    });

                    laydate.render({
                        elem: '#endTime',
                        type: 'datetime'
                    });

                    that.$nextTick(function () {
                        form.render();
                    });
                },
                getMentionMoneyByMoneyType: function () {
                    var that = this;
                    table.render({
                        elem: '#currentTableId',
                        url: wp.url('/wp/ewallet/wallet/reqOrder/moneyType/mentionMoney'),
                        where:{
                            moneyType:that.moneyType
                        },
                        headers: wp.getAjaxHeaders(),
                        parseData: wp.parseGridData,
                        cols: [[
                            {field: 'reqOrderId', title: '申请单ID', templet: '#operTpl'},
                            {field: 'reqType', title: '申请类型', templet: '#applyTypeTpl'},
                            {field: 'moneyTypeCode', title: '币种类型'},
                            {field: 'userTel', title: '申请用户'},
                            {field: 'createDate', title: '申请时间'},
                            {field: 'status', title: '状态', templet: '#statusTpl', align: 'center'}
                        ]],
                        limits: wp.config.pageList,
                        limit: wp.config.pageSize,
                        page: true
                    });

                    table.on('tool(currentTableFilter)', function (obj) {
                        var data = obj.data;
                        if (obj.event === 'detail') {
                            that.detail(data);
                        }
                    });
                },
                detail: function (data) {
                    var self = this;
                    var url = wp.resUrl('/wpui-admin/wp-ewallet-admin/module/wallet/wallet-apply-querydetail-money.html');
                    if ('1000' == data.orderStatus) {
                        url = wp.resUrl('/wpui-admin/wp-ewallet-admin/module/wallet/wallet-apply-money.html');
                    }
                    var title = '提币申请详情';
                    // Demo暂用中文，实现时替换成类型码字段和值
                    if (data.reqType == '2000') {
                        url = wp.resUrl('/wpui-admin/wp-ewallet-admin/module/wallet/wallet-apply-querydetail-redeem.html');
                        if ('1000' == data.orderStatus) {
                            url = wp.resUrl('/wpui-admin/wp-ewallet-admin/module/wallet/wallet-apply-redeem.html');
                        }
                        var title = '兑换申请详情';
                    }

                    // 添加到tab
                    var iframeWindow = wp.addTab(url, title);
                    iframeWindow.walletApplyVm = self;
                    iframeWindow.data = data;
                    // 窗口关闭方法
                    iframeWindow.close = function () {
                        wp.closeTab(iframeWindow.tabId);
                    }
                    iframeWindow.onLoadFinish = function (vm) {

                    }
                },
                search: function () {
                    var that = this;
                    // 查询参数
                    var queryParam = form.val("myform");
                    queryParam.moneyType = that.moneyType;
                    // alert("queryParam"+JSON.stringify(queryParam));
                    // 执行搜索重载
                    table.reload('currentTableId', {
                        page: {curr: 1},
                        where: queryParam
                    });
                },
                reset: function () {
                    $("#myform").get(0).reset();
                    this.getMentionMoneyByMoneyType();
                }
            }
        });
    });
</script>
<script>

</script>

</body>
</html>